<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <textarea id="test" name="" id="" cols="30" rows="10"></textarea>
    </div>
</body>
<script src="js/MathJax/tex-chtml.js"></script>
<script src="js/marked.min.js"></script>
<script src="js/marked_extension.js"></script>
<script>


    // marked.use({
    //     extensions: [{
    //         name: 'code',
    //         renderer(token) {
    //             console.log(token);
    //             return token.text;
    //         }
    //     }]
    // })

    // const mathExtension = {
    //     name: 'math',
    //     level: 'block',                                     // Is this a block-level or inline-level tokenizer?
    //     start(src) { return src.match(/^\$\$/)?.index; }, // Hint to Marked.js to stop and check for a match
    //     tokenizer(src, tokens) {
    //         const rule = /^\$\$(.+?)\$\$$/;    // Regex for the complete token, anchor to string start
    //         const match = rule.exec(src);
    //         if (match) {
    //             const token = {                                 // Token to generate
    //                 type: 'math',                      // Should match "name" above
    //                 raw: match[0],                                // Text to consume from the source
    //                 text: match[1].trim(),                        // Additional custom properties
    //                 tokens: []                                    // Array where child inline tokens will be generated
    //             };
    //             //this.lexer.inline(token.text, token.tokens);    // Queue this data to be processed for inline tokens
    //             return token;
    //         }
    //     },
    //     renderer(token) {
    //         return `math: ${token.text},mathend\n`; // parseInline to turn child tokens into HTML
    //     }
    // };

    marked.use({ extensions: [mathExtension] });
    var text = "$$a=b$$";
    var result = marked.lexer(text);
    console.log(result);
    result = marked.marked(text);
    //document.getElementById("test").outerHTML = result;
    console.log(result);
</script>
</html>